package com.panda.business.task;


import com.panda.order.domain.TPandaOrderHead;
import com.panda.order.service.ITPandaOrderHeadService;
import com.panda.order.taobao.TbGetOrderListApi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 * 同步管家婆订单
 */
@Component("getTbOrdeTask")
public class GetTbOrdeTask {
    private static final Logger log = LoggerFactory.getLogger(GetTbOrdeTask.class);

    @Autowired
    private TbGetOrderListApi getOrderListApi;

    @Autowired
    private ITPandaOrderHeadService orderHeadService;

    public void getOrderList(Date lastRun){
        log.info("同步淘宝订单开始！");
        // 查询未完成操作
        List<TPandaOrderHead> orderHeads = getOrderListApi.doGetTbOrder(lastRun);
        log.info("同步淘宝订单，获取订单数{}！",orderHeads.size());

        // 入库
        orderHeadService.saveTbOrderList(orderHeads);
    }
}
